﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MVCExtension.FrameWork;
using System.Data;

namespace MVCExtension.Authorize
{
    [ExceptionLog]
    class LogOnAction
    {
        /// <summary>
        /// 检查用户是否有权限访问功能
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static Boolean CheckUserPower(string controller,string action)
        {
             
            string sql="select top 1 * from ControllerActionList where controller='{0}' and action='{1}' order by id desc";

            sql=string.Format(sql,controller,action);

            Logger.Debug(sql);
            DataTable dt=DBHelper.GetDataTable(sql,controller+action);

             
            if(dt.Rows.Count==0) 
            {
                return false;
            }
            else
            {
                bool flag = StringHelper.String2ArrayList(dt.Rows[0]["usergroupId"].ToString(), ',').Contains(MasterHelper.UserRoleID);

            return flag;
            }
        }




        /// <summary>
        /// 检查用户是否具有此菜单的访问权限
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static Boolean CheckMenu(string controller, string action)
        {
            return true;
        }
    }
}
